<%- include('css') %>
<div id="app" style="width:980px">
    <fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
        <legend>查看干洗中心</legend>
    </fieldset>

    <form class="layui-form layui-form-pane" action="" lay-filter="form">

        <div class="layui-form-item" pane>
            <label class="layui-form-label">干洗中心名称</label>
            <div class="layui-input-block">
                <input type="text" name="name" lay-verify="required" placeholder="请输入姓名" autocomplete="off" class="layui-input" disabled>
            </div>
        </div>

        <div class="layui-form-item" pane>
            <label class="layui-form-label">负责人姓名</label>
            <div class="layui-input-block">
                <input type="text" name="realname" lay-verify="required" placeholder="请输入姓名" autocomplete="off" class="layui-input" disabled>
            </div>
        </div>


        <div class="layui-form-item" pane>
            <label class="layui-form-label">联系电话</label>
            <div class="layui-input-block">
                <input type="text" maxlength="11" name="phone" lay-verify="required|phone" placeholder="请输入联系电话" autocomplete="off" class="layui-input" disabled>
            </div>
        </div>



        <div class="layui-form-item" pane>
            <label class="layui-form-label">省市</label>
            <div class="layui-input-block">
                <input type="text" name="province" lay-verify="required|province" placeholder="请输入省市" autocomplete="off" class="layui-input" disabled>
            </div>
        </div>

        <div class="layui-form-item" pane>
            <label class="layui-form-label">具体地址</label>
            <div class="layui-input-block">
                <input type="text" name="address" lay-verify="required|address" placeholder="请输入具体地址" autocomplete="off" class="layui-input" disabled>
            </div>
        </div>


        <div class="layui-form-item">
            <div class="layui-input-block">
                <button type="button" v-on:click="doclose" class="layui-btn layui-btn-primary">关闭</button>
            </div>
        </div>
    </form>
</div>

<%- include('script') %>
<script>

    var vm = new Vue({
        el: '#app',
        data:function(){
            return {
                isButtonDisabled:false,
                id:'<%=id%>',
            }

        },
        mounted:function(){

            var self = this;
            layui.use(['form'], function () {
                var form = layui.form;

                var l = layer.load();

                $.ajax({
                    url:'/admin/center/'+self.id,
                    type:'GET',
                    data:{},
                    success:(res)=>{
                        if(res.code === 200){
                            form.val("form",res.data);
                            layer.close(l);
                        }else{
                            var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
                            parent.layer.close(index); //再执行关闭
                            parent.layer.msg('获取数据失败：'+res.error+' -- '+res.code,{icon:2});
                        }
                    },
                    fail:()=>{
                        layer.close(l);
                        var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
                        parent.layer.close(index); //再执行关闭
                        parent.layer.msg('请求获取数据失败',{icon:2});
                    }
                });

            });
        },

        methods:{
            doclose:function(){
                parent.vm.iframeclose();
                var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
                parent.layer.close(index); //再执行关闭
            },
        }
    })
</script>
